#include "logindialog.h"

LoginDialog::LoginDialog()
{
   userlab=new QLabel(this);
   userlab->move(70,80);
   userlab->setText(tr("Account"));

   userEdit=new QLineEdit(this);
   userEdit->move(140,80);
   userEdit->setPlaceholderText(tr("please input your account"));

   pwdlab=new QLabel(this);
   pwdlab->move(70,130);
   pwdlab->setText(tr("Password"));

   pwdEdit=new QLineEdit(this);
   pwdEdit->move(140,130);
   pwdEdit->setEchoMode(QLineEdit::Password);
   pwdEdit->setPlaceholderText(tr("please input your password"));

   loginbtn=new QPushButton(this);
   loginbtn->move(50,200);
   loginbtn->setText(tr("login"));

   quitbtn=new QPushButton(this);
   quitbtn->move(210,200);

    connect(loginbtn,&QPushButton::clicked,this,&LoginDialog::login);
    connect(quitbtn,&QPushButton::clicked,this,&LoginDialog::close);
}

LoginDialog::~LoginDialog(){

}

void LoginDialog::login(){
    if(userEdit->text().trimmed()==tr("json96")&&pwdEdit->text().trimmed()==(tr("123456hj")))
    {
        accept();
    }
    else
    {
        QMessageBox::warning(this,tr("waring"),tr("account and password not is invaild"),QMessageBox::Yes);
        userEdit->clear();
        pwdEdit->clear();
        userEdit->setFocus();
    }
}
